package com.neusoft.eenie.signdemo.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.neusoft.eenie.signdemo.R;
import com.neusoft.eenie.signdemo.bean.SignInfo;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Eenie on 2016/3/25.
 */
public class NameListAdapter extends BaseAdapter {

    List<SignInfo> infos = new ArrayList<>();
    Context context;

    public NameListAdapter(Context context,List<SignInfo> infos) {
        this.infos = infos;
        this.context = context;
    }


    public void replaceData(List<SignInfo> infos) {
        this.infos = infos;
    }



    @Override
    public int getCount() {
        return infos.size();
    }

    @Override
    public Object getItem(int position) {
        return infos.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        CheckNameHolder holder;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.item_name_list, null);
            holder = new CheckNameHolder(convertView);
            convertView.setTag(holder);
        } else {
            holder = (CheckNameHolder) convertView.getTag();
        }
        holder.bindData(infos.get(position));
        return convertView;
    }
}
